<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=0,maximum-scale=1.0" />
	<script src="http://g.tbcdn.cn/mtb/lib-flexible/0.3.4/??flexible_css.js,flexible.js"></script>
	<link rel="stylesheet" type="text/css" href="css/reset.css"/>
	<link rel="stylesheet" type="text/css" href="css/style.css"/>
	<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/public.js" type="text/javascript" charset="utf-8"></script>
	<title>扫码点餐</title>

</head>
<body>
<div id="home">
	<div class="home_con">
		<img class="bg_top" src="images/home_t.png"/>
		<div class="con_list">
			<img class="logo" src="images/logo.png"/>
			<h3>邦伲德点餐(上海店）</h3>
			<h2>  </h2>
			<h5>请选择点餐人数</h5>
			<ul id="peoples">
				<li>1</li>
				<li>2</li>
				<li>3</li>
				<li>4</li>
				<li>5</li>
				<li>6</li>
				<li>7</li>
				<li>8</li>
				<li>9</li>
				<li>10</li>
				<li>11</li>
				<li>12</li>
			</ul>
			<button class="dc_btn" onclick="goMenu()">开始点餐</button>
			<div class="explain">
				成为会员享受更多优惠权益
				<a href="javascript:void(0);" class="go_kt">去开通</a>
			</div>
			<div class="ft_txt">由邦伲德提供技术支持</div>
		</div>
		<p></p>
		<img class="bg_btm" src="images/home_b.png"/>
	</div>
	<input type="hidden" name="pnum" id="pnum" value="" />
	<input type="hidden" name="table" id="table"  />
	<input type="hidden" name="store_id" id="store_id"  />
</div>
<script type="text/javascript">
    //	//适配
    //(function() {
    //      var newRem = function() {
    //          var html = document.documentElement;
    //          html.style.fontSize = html.getBoundingClientRect().width / 16 + 'px';
    //      };
    //      window.addEventListener('resize', newRem, false);
    //      newRem();
    //  })();

    $(function () {
        (function ($) {
            $.getUrlParam = function (name) {
                var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
                var r = window.location.search.substr(1).match(reg);
                if (r != null) return unescape(r[2]);
                return '';
            }
        })
        (jQuery);
        $("#table").val($.getUrlParam('table'));
        $("#store_id").val($.getUrlParam('store_id'));

        //清空购物车
        $.ajax({
            url:url() + "index.php/Api/Car/del",
            dataType:"json",
            type:"get",
            success:function (data){
                console.log(data)
            }
        })
        //授权
        getUserInfo();
        goMenu();
    })

    $('#peoples li').on('click',function(){
        var _this=$(this).index();
        $(this).addClass('active').siblings().removeClass('active')
        $('#pnum').val(_this+1)
    })

    function getUserInfo() {
        var store_id=$("#store_id").val();
        $.ajax({
            url: url() + 'index.php/Api/Index/getUserInfo',    //请求的url地址
            dataType: "json",   //返回格式为json
            async: true,//请求是否异步，默认为异步，这也是ajax重要特性
            type: "GET",   //请求方式
			data: {
                	store_id:store_id,
				},
            success: function (data) {
                if(data.state == 1){
                    window.location.href = url() + "index.php?m=Api&c=WeChat&a=start&store_id="+store_id;//微信授权登录
                }else{
                    console.log(data)
                    var storage=window.localStorage;
                    storage.setItem("customer_id",data.data.customer_id)
                }
            }
        });
    }
    function goMenu(){
        var pnum = $('#pnum').val()
        var table = $("#table").val();
        if(pnum<=0){
            alert('请选择就餐人数')
		}else {
            $.ajax({
                url:url() + "index.php?s=/Api/DishesOrder/getPerson",
                data:{'id':pnum},
                dataType:"json",
                type:"post",
                success:function (data) {
                    console.log(data);
                    window.location.href = url() + "html/meal_new/menu.html?pnum=" + pnum +"&znum="+ table;
                }
            })
		}
    }

</script>
</body>
</html>